3.6 Using labels
Tabulations and other statistical output become more understandable by attaching text-labels to the various categorical variable values. Microdata.no makes it possible to define a set of value labels to be attached to all variables sharing the same type of categorization:
define-labels <label-set name> <value1> <label1> <value2> <label2> ... <valuen> <labeln>
assign-labels <variable> <label-set name>
Labels are first made using define-labels
, and then they are attached to the relevant variable(s) in the next stage.
Example of a categorical (alphanumerical) residency variable at county level (variable county). The label set named "countystring" can, through the command assign-labels
, be attached to as many variables as possible, given that they share the same type of value set (it is not necessary to create the same set of labels several times):
define-labels countystring '01' 'Østfold' '02' 'Akershus' '03' 'Oslo' '04' 'Hedmark' '05' 'Oppland' '06' 'Buskerud' '07' 'Vestfold' '08' 'Telemark' '09' 'Aust-Agder' '10' 'Vest-Agder' '11' 'Rogaland' '12' 'Hordaland' '14' 'Sogn and Fjordane' '15' 'Møre and Romsdal' '16' 'Sør-Trøndelag' '17' 'Nord-Trøndelag' '18' 'Nordland' '19' 'Troms' '20' 'Finnmark' '99' 'Unknown'
assign-labels county countystring
Note: If the variable contains numerical values, the values in the define-labels
expression need to be specified without quotation marks. The labels that are linked to the values do not need to have quotation marks around if they only contain letters. But labels that contain special characters such as spaces, hyphens, slashes, dots, etc., must have quotation marks around. If you are unsure, you can always use quotation marks around labels no matter what.
It is also allowed to use double quotation marks if preferred.
Text-labels must not contain commas, as this will result in error messages when executing (the comma character is reserved by the system to indicate the use of options).
[Examples of facilitating variables and use of label functionality](i18n\en\docusaurus-plugin-content-docs\current\eksempel\Grunnleggende operasjoner\Tilrettelegge variabler - dummy- og flerkategorivariabler - funksjoner - labler.md)